package zhupf.test.juc;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompleteTableFutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
       CompletableFuture<Void> completedFuture = CompletableFuture.runAsync(()-> System.out.println("22222"));
        completedFuture.get();

        int i = CompletableFuture.supplyAsync(()->{
            System.out.println("come on ");
            int t = 10/0;
            return 1024;
        }).whenComplete((t,u)->{
            System.out.println("******:"+t);
            System.out.println("******:"+u);
        }).exceptionally(x->{
            System.out.println("************"+x);
            return 4444;
        }).get();
        System.out.println(i);

    }
}
